### Replication script for: '“An isolating experience aggravated by COVID”: Exploring disconnections between political science PhD candidates and supervisors' 
# Note: The figures in this paper were  were created using Canva, an online graphics platform, not R.

### Loading data ###
data <- read.csv("can_sup_Data.csv")
# Note: We do not have access to a raw data file for the 2013 data (Kefford and Morgenbesser 2013). We were given the survey results after reaching out to Kefford.


################################################################################

### SECTION 3. METHODS AND DEMOGRAPHICS ###

# Gender
table(data$Q1001C)

# Age
table(data$Q1002C)

# Domestic/International status
table(data$Q1003C)

# Full-time/Part-time status
table(data$Q102C)

# Group of Eight Universities
data$Go8 <- ifelse(data$Q108C == 6, 1, 
                    ifelse(data$Q108C == 8, 1,
                      ifelse(data$Q108C == 15, 1,
                        ifelse(data$Q108C == 18, 1,
                          ifelse(data$Q108C == 24, 1,
                            ifelse(data$Q108C == 31, 1,
                              ifelse(data$Q108C == 35, 1,
                                ifelse(data$Q108C == 38, 1,2))))))))
table(data$Go8)


################################################################################

### SECTION 4. IMPACT OF COVID-19 ON THE PhD PROGRAM ###

# Experience of COVID-related challenges (used for Figure 2)
table(data$Q801C_1) # Candidate responses
table(data$Q701S_1) # Supervisor responses
# Testing for a correlation between the % of candidates who report having experienced a challenge,
# and the % of supervisors who indicate their students have experienced a challenge
df_challenges <- data.frame("candidates"=c(86,74,71,56,51,34,33),
                            "supervisors"=c(96,100,93,76,78,42,58))
cor.test(df_challenges$candidates,df_challenges$supervisors, method="pearson")

# Year of study (used for Figure 3)
table(data$Q101C) 
# Testing for difference between the % of candidates in a particular year of study in 2022 v 2013
df_studyYear <- data.frame("1" = c(43,15),"2"=c(43,30), "3"=c(46,21), "4"=c(38,27), "5+"=c(10,14))
chisq.test(df_studyYear)


################################################################################

### SECTION 5. DEPARTMENTAL SUPPORT FOR COVID-19-RELATED CHALLENGES ###

# Departmental support for COVID (used for Figure 4)
table(data$Q802C) # Candidate responses
table(data$Q702S) # Supervisor responses
# Testing for difference between responses of candidates and supervisors
df_support_covid <- data.frame("no, none" = c(15,2),"yes, some"=c(58,34),"yes, a lot"=c(6,8), "don't know"=c(9,2))
fisher.test(df_support_covid)

# Satisfaction with departmental support in relation to COVID
table(data$Q803C) # Candidate responses
table(data$Q703S) # Supervisor responses
# Testing for difference between responses of candidates and supervisors
df_support_covid_satisfied <- data.frame("not at all" = c(24,9),"a little"=c(21,11),"somewhat"=c(23,21), "very"=c(9,3), "don't know"=c(3,1))
fisher.test(df_support_covid_satisfied)

# Satisfaction with departmental support in relation to covid, by satisfaction with support in general
prop.table(table(data$Q606C,data$Q803C),1)
df_satisfaction <- data.frame("not at all"=c(10,12,2),"a little"=c(7,11,3), "somewhat"=c(5,17,1), "very"=c(0,9,0), "don't know"=c(0,3,0))
fisher.test(df_satisfaction)

# Satisfaction with support from supervisors & support staff (used for Figure 5)
table(data$Q606C)
# Testing for difference between responses of candidates in 2022 v 2013
df_support <- data.frame("yes" = c(126,60),"no"=c(38,24),"don't know"=c(5,9))
chisq.test(df_support)


################################################################################

### SECTION 6. IMPACT ON COVID-19 ON FUTURE CAREER PLANS ###

# Intention to pursue career in academia (used in Figure 6)
prop.table(table(data$Q702C))

#Covid impact on career plans, by cohort (used for Figure 7)
table(data$Q101C,data$Q804C) # First and second year = "inter-covid" cohort; third year and above = "pre-covid" cohort
df_careerPlans_cohort <- data.frame("not at all" = c(23,24),"somewhat"=c(21,7), "a lot"=c(7,5))
chisq.test(df_careerPlans_cohort)

# Impact of COVID on career plans (used for Figure 8)
prop.table(table(data$Q804C)) # Candidates
prop.table(table(data$Q704C)) # Supervisors
# Testing for difference between responses of candidates and supervisors
df_careerPlans_cansup <- data.frame("not at all" = c(47,8),"somewhat"=c(28,22), "a lot"=c(12,3))
fisher.test(df_careerPlans_cansup)

#Career mentoring style (used for Figure 9)
prop.table(table(data$Q601C)) # Candidates
prop.table(table(data$Q501S)) # Supervisors
# Testing for difference between responses of candidates and supervisors
df_careerMentoring_cansup <- data.frame("academic" = c(19,8),"both"=c(20,36), "non-ac"=c(1,2), "none"=c(56,2))
fisher.test(df_careerMentoring_cansup)

